package com.common.help.test07;

import java.util.Random;

public class Test2 {
	
	public static Shape selectShape(){
		Random r = new Random();
		switch(r.nextInt(10)%3){
		case 0:return new Circle();
		case 1:return new Square();
		case 2:return new Triangle();
		default:return new Shape();
		}
	}
	
	public static void main(String[] args) {
		Shape[] shapes = new Shape[9];
		for(int i=0;i<shapes.length;i++){
			shapes[i] = selectShape();
		}
		for(Shape shape : shapes){
			shape.draw();
			shape.erase();
		}
 	}

}
class Shape { 
	  void draw() {}
	  void erase() {} 
	}

	class Circle extends Shape {
	  void draw() { 
	    System.out.println("Circle.draw()"); 
	  }
	  void erase() { 
	    System.out.println("Circle.erase()"); 
	  }
	}

	class Square extends Shape {
	  void draw() { 
	    System.out.println("Square.draw()"); 
	  }
	  void erase() { 
	    System.out.println("Square.erase()"); 
	  }
	}

	class Triangle extends Shape {
	  void draw() { 
	    System.out.println("Triangle.draw()"); 
	  }
	  void erase() { 
	    System.out.println("Triangle.erase()");
	  }
	}
